package com.bawei.fuxi.ui.friends;

import android.animation.ObjectAnimator;
import android.view.View;
import android.widget.ImageView;

import com.bawei.fuxi.R;
import com.bawei.fuxi.base.mvp.BaseView;
import com.bawei.fuxi.base.utils.GlideUtils;
import com.bawei.fuxi.entity.VideoEntity;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;

import androidx.annotation.NonNull;
//多布局适配器
public class VideoAdapter extends BaseMultiItemQuickAdapter<VideoEntity.DataBean, BaseViewHolder> {
    public VideoAdapter() {
        addItemType(0, R.layout.item_video);
        addItemType(1,R.layout.item_video_zhibo);
        addItemType(2,R.layout.item_video_full);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, VideoEntity.DataBean dataBean) {
        switch (dataBean.getItemType()){//判断类型
            case 0://视频
            case 2://全屏观看
            {   //视频
                StandardGSYVideoPlayer gsy = baseViewHolder.getView(R.id.gsy);
                gsy.setUp(dataBean.getVideopath(),true,"");
                gsy.getBackButton().setVisibility(View.GONE);
                //描述
                baseViewHolder.setText(R.id.tv_caption,dataBean.getCaption()+"");
                //用户名
                baseViewHolder.setText(R.id.tv_username,dataBean.getAuthname()+"");
                //地址
                baseViewHolder.setText(R.id.tv_address,dataBean.getAddress()+"");
                //跑马灯
                baseViewHolder.setText(R.id.tv_pao,dataBean.getAuthname()+"创走的原生作品");
                //头像
                ImageView ivUser = baseViewHolder.getView(R.id.iv_user);
                GlideUtils.getInstance().loadCircleImage(getContext(),dataBean.getHeadpath(),ivUser);
                //转盘:动画自己写
                ImageView ivZhuan = baseViewHolder.getView(R.id.iv_zhuan);
                GlideUtils.getInstance().loadCircleImage(getContext(),dataBean.getHeadpath(),ivZhuan);

                //是否点赞过
                ImageView ivZan = baseViewHolder.getView(R.id.iv_dianzan);
                if(dataBean.getDianzan() == 0){//没赞
                    ivZan.setImageResource(R.drawable.ic_xihuan);
                }else{//赞
                    ivZan.setImageResource(R.drawable.ic_xihuanred);
                }
                //是否关注过
                ImageView ivAdd = baseViewHolder.getView(R.id.iv_add);
                if(dataBean.getGuanzhu() == 0){//没关注
                    ivAdd.setVisibility(View.VISIBLE);
                }else{//关注
                    ivAdd.setVisibility(View.GONE);
                }
            }
                break;
            case 1://直播
            {
                //视频
                StandardGSYVideoPlayer gsy = baseViewHolder.getView(R.id.gsy);
                gsy.setUp(dataBean.getVideopath(),true,"");
                gsy.getBackButton().setVisibility(View.GONE);
                //描述
                baseViewHolder.setText(R.id.tv_caption,dataBean.getCaption()+"");
                //用户名
                baseViewHolder.setText(R.id.tv_username,dataBean.getAuthname()+"");
                //地址
                baseViewHolder.setText(R.id.tv_address,dataBean.getAddress()+"");
                //跑马灯
                baseViewHolder.setText(R.id.tv_pao,dataBean.getAuthname()+"创走的原生作品");
            }
                break;
        }
    }
}
